<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"> 
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
        <link type="text/css" href="__PUBLIC__/css/jquery-weui.min.css" rel="stylesheet">
		<link type="text/css" href="__PUBLIC__/css/weui.min.css"  rel="stylesheet"/>
        <link type="text/css" href="__PUBLIC__/css/app.css"  rel="stylesheet"/>
		<title>推广注册</title>
	</head>
	<body style="background-image:url(__PUBLIC__/images/tui_sjcr_img.png);background-repeat:no-repeat;background-size: 100%;"> 
		<div class="tui_bg" style="margin-top:90%; background: none;  ">
			<!-- <img src="__PUBLIC__/images/tui_sjcr_img.png" style="width: 100%;">  style="background:#fc6637;" -->
			<!-- <section class="tui_span">
				<span>微投入轻创业</span>
				<span>个人专属贷款超市</span>
				<span>信贷中介必备</span> 
			</section> -->
		<form action="#" method="post" id="formf">
			<section class="input_block">
				<input type="text" name="Mobile" id="Mobile" placeholder="请输入手机号" />
			</section>
			
			<section class="input_block">
			   <input name="ImgCode" id="ImgCode" type="text" value="" style="width: 60%;" placeholder="图形验证码">
			   <img style="width:36%;display: inline-block;vertical-align: middle" src="<?php echo U('index.php/Common/selfverify');?>" id="imgValidateCode" onclick="this.src='<?php echo U('index.php/Common/selfverify');?>#'+Math.random();" height="38" width="100px">
			   <div class="clear"></div>
		    </section>

			<section class="input_block">
				<input id="MsgCode" name="MsgCode" type="text" placeholder="请输入短信验证码">
				<a href="javascript:void(0);" id="getcode" onclick="getcode()" class="huo_yan"> 获取验证码</a>
			</section>


			<section class="input_block">
				<input id="Password" name="Password" type="password" placeholder="密码">
			</section>
			<input type="hidden" name="puser" id="puser" value="{$puser}">
		</form>	
			<a class="input_block input_block1" style="background: #ffc630;" href="javascript:void(0);" onclick="fnRegister()">马上申请</a>
			
			<!-- <p class="center" style="color:white;">
				点击按钮则视为同意<a href="{:U('News/pages',array('ID'=>5))}" style="color:#f02f2d;">{$Title}</a>
			</p>  -->
			<!-- <p class="center" style="color:white;font-size:20px;padding-bottom:10px;">泰州市天铎网络科技有限公司</a>
			</p>  -->
		</div> 
		
		<script src="__PUBLIC__/JS/jquery-2.1.4.js"></script>
		<script src="__PUBLIC__/JS/jquery-weui.min.js"></script> 
		<!--<script src="__PUBLIC__/JS/common.js"></script>-->  
	</body>
</html>
<script type="text/javascript">
			//启用倒计时
			function times() {
				var setTime;
				var time = 60;
				setTime = setInterval(function () {
					if (time <= 0) {
						clearInterval(setTime);
						//添加事件
						$("#getcode").attr("onclick", "getcode()");
						$("#getcode").text('发送验证码');
						return;
					}
					time--;
					msgs = time + "s后重发";
					$("#getcode").text(msgs);
				}, 1000);
			}

			//获取验证码
			function getcode() {
				var mobile = $.trim($("#Mobile").val());
				var code = $.trim($("#ImgCode").val());

				if (mobile == '') {
					$.alert("手机号码不能为空！");
					return false;
				}
				if (!mobile.match(/^((1[3-9][0-9]{1})+\d{8})$/)) {
					$.alert("手机号码格式不正确！");
					return false;
				}
				if (code == '') {
					$.alert("请输入图形验证码！");
					return false;
				}
				$.ajax({
					type: 'post',
					url: '{:U("index.php/Common/getcode")}',
					data: {mobile: mobile,code:code,check: 1},
					dataType: 'json',
					success: function (res) {
						if (res.result==1) {
							times();
							$("#getcode").removeAttr("onclick");
						}
						if (res.result==2) {
							$.alert(res.message);
						}
						if (res.result==3) {
							alert(res.message);
		                    window.setTimeout(function(){
		                        window.location.href = "{$extension_url}";
							}, 1000);
						}
						if (res.result==0) {
							alert(res.message);
		                    
						}
					}
				});
			}

			//注册
			function fnRegister() {
				var Mobile = $.trim($('#Mobile').val());
				var Password = $.trim($("#Password").val());
				var MsgCode = $.trim($('#MsgCode').val());

				if (Mobile == '') {
					$.alert("请输入手机号码");
					return false;
				}
				if (!Mobile.match(/^((1[3-9][0-9]{1})+\d{8})$/)) {
					$.alert("手机号码格式不正确！");
					return;
				}
				if (MsgCode == '') {
					$.alert("短信验证码不能为空！");
					return false;
				}
				if (Password == '') {
					$.alert("请输入您的密码，以英文字母开头，6-16位与数字的组合");
					return false;
				}
//				if (!Password.match(/^[a-zA-Z]\w{5,15}$/)) {
//					$.alert("密码必须是以英文字母开头，6-16位与数字的组合");
//					return false;
//				}


				$.ajax({
					type: "POST",
					url: "<?php echo U('index.php/Register/ajaxRegister');?>",
					data: $('#formf').serialize(),
					dataType: "json",
					success: function (data) {
						if (data.result == 1) {
							//成功
							// XB.Success(data.message, function () {
							// 	window.location.href = "<?php echo U('Login/index');?>";
							// });
							$.alert(data.message, "", function() {
							  //点击确认后的回调函数
							  // window.location.href = "<?php echo $GLOBALS['BasicInfo']['Downurl'];?>";
							  window.location.href = "{$extension_url}";
							});
						} else {
							$.alert(data.message);
						}
					}
				});
			}
		</script>